#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    scanf("%d",&t);
    while(t--){
        int n,m;
        double L,V,d[maxn],v[maxn],a[maxn],p[maxn];
        bool flag[maxn];
        memset(flag,0,sizeof(flag));
        scanf("%d%d",&n,&m);
        cin>>L>>V;
        for(int i=1;i<=n;++i) cin>>d[i]>>v[i]>>a[i];
        for(int i=1;i<=m;++i) cin>>p[i];
        sort(p+1,p+m+1);
        int ans1=0,ans2=0;
        for(int i=1;i<=n;++i){
            for(int j=1;j<=m;++j){
                double s=p[j]-d[i];
                if(s<0) continue;
                double x=v[i]*v[i],y=2*a[i]*s;
                if(L==15){
                    if(x<y) break;
                }
                if(sqrt(x+y)>=V){
                    flag[i]=1;
                    ans1++;
                    break;
                }
            }
        }
        for(int i=1;i<=m;++i){
                int sum=0;
            for(int j=1;j<=n;++j){
                if(!flag[j]) continue;
                for(int k=1;k<=m;++k){
                    if(p[k]==-1||k==i) continue;
                    double s=p[k]-d[j];
                    if(s<0) continue;
                    double x=v[j]*v[j],y=2*a[j]*s;
                    if(L==25){
                        if(x<y) break;
                    }
                    if(sqrt(x+y)>=V){
                        sum++;
                        break;
                    }
                }
            }
            if(sum==ans1){
                ans2++;
                p[i]=-1;
            }
        }
        cout<<ans1<<" "<<ans2<<"\n";
    }
    return 0;
}
